package com.dys.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @className: com.dys.controller.RestFulController
 * @description: RestFul软件架构风格
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/10/25 23:16
 */
// @RestController
@Controller
public class RestFulController {

    @RequestMapping(value = {"/testRestFulByGet/{id}"}, method = {RequestMethod.GET})
    public String testRestFulByGet(@PathVariable("id") Integer id) {
        System.out.println("RestFul get 软件架构风格......");
        System.out.println("url中的id: " + id);
        return "/restFulSuccess";
    }

    @RequestMapping(value = {"/testRestFulByPost/{id}"}, method = {RequestMethod.POST})
    public String testRestFulByPost(@PathVariable("id") Integer id) {
        System.out.println("RestFul post 软件架构风格......");
        System.out.println("url中的id: " + id);
        return "/restFulSuccess";
    }

    @RequestMapping(value = {"/testRestFulByPut/{id}"}, method = {RequestMethod.PUT})
    public String testRestFulByPut(@PathVariable("id") Integer id) {
        System.out.println("RestFul put 软件架构风格......");
        System.out.println("url中的id: " + id);
        return "/restFulSuccess";
    }

    @DeleteMapping(value = {"/testRestFulByDelete/{id}"})
    public String testRestFulByDelete(@PathVariable("id") Integer id) {
        System.out.println("RestFul delete 软件架构风格......");
        System.out.println("url中的id: " + id);
        return "/restFulSuccess";
    }

    // Patch请求
    @RequestMapping(value = "/patchId/{id}", method = RequestMethod.PATCH)
    public String patchId(@PathVariable("id") String id) {
        System.err.println("PATCH --> " + id);
        return "/restFulSuccess";
    }


    // HEAD请求
    @RequestMapping(value = "/headId/{id}", method = RequestMethod.HEAD)
    public String headId(@PathVariable("id") String id) {
        System.err.println("HEAD --> " + id);
        return "/restFulSuccess";
    }

    // Options请求
    @RequestMapping(value = "/optionsId/{id}", method = RequestMethod.OPTIONS)
    public String optionsId(@PathVariable("id") String id) {
        System.err.println("OPTIONS --> " + id);
        return "/restFulSuccess";
    }

    // Trace请求
    @RequestMapping(value = "/trachId/{id}", method = RequestMethod.TRACE)
    public String trachId(@PathVariable("id") String id) {
        System.err.println("TRACH --> " + id);
        return "/restFulSuccess";
    }
}
